﻿namespace ClassyBlog.Infrastructure
{
    using System;
    using System.Web;
    using System.Web.Routing;

    using Web;

    public class ArchivedDatesConstraint : IRouteConstraint
    {
        public virtual bool Match(
            HttpContextBase httpContext,
            Route route,
            string parameterName,
            RouteValueDictionary values,
            RouteDirection routeDirection)
        {
            try
            {
                ArchivedDates.CreateFrom(values);

                return true;
            }
            catch (ArgumentException)
            {
            }

            return false;
        }
    }
}